package com.example.transaction;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.sql.Types;
import java.util.Collections;

public class CodeGenerator {
    public static void main(String[] args) {
        String moudle="sys";
        String mapperLocation="/Users/zhanghong/Desktop/SpringBoot-Shiro-Vue-master/SpringBoot-Shiro-Vue-master/Transaction/src/main/resources/mapper/"+moudle;
        String tables="classfy,item_classfy,address,User,Item,Order,Comment,Announcement,Demand,LoginLog";
        FastAutoGenerator.create("jdbc:mysql://localhost:3306/Transaction?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai", "root", "qwzp13118286511")
                .globalConfig(builder -> {
                    builder.author("zh") // 设置作者
                            //.enableSwagger() // 开启 swagger 模式
                            //.fileOverride() // 覆盖已生成文件
                            .outputDir("/Users/zhanghong/Desktop/第二次实训/Transaction/src/main/java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.example.transaction") // 设置父包名
                            .moduleName(moudle) // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, mapperLocation)); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude(tables) // 设置需要生成的表名
                            .addTablePrefix("x_"); // 设置过滤表前缀
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }
}
